package com.zxy.ider.ehome.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.ider.deskcust.TileEntry;
import com.zxy.ider.ehome.Appcontext;
import com.zxy.ider.ehome.R;
import com.zxy.ider.ehome.View.TitleTextView;
import com.zxy.ider.ehome.bean.MyFile;

import java.util.List;

/**
 * Created by ider-eric on 2017/5/27.
 */

public class FileAdapter extends BaseAdapter {
    private List<MyFile> files;

    public FileAdapter(List<MyFile> files) {
        this.files = files;
    }

    @Override
    public int getCount() {
        return files.size();
    }

    @Override
    public Object getItem(int i) {
        return files.get(i);
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        GridViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new GridViewHolder();
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_file, parent, false);
            viewHolder.iconview = (ImageView) convertView.findViewById(R.id.file_icon);
            viewHolder.title = (TitleTextView) convertView.findViewById(R.id.file_name);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (GridViewHolder) convertView.getTag();
        }
        viewHolder.iconview.setImageDrawable(files.get(position).getFileIcon());
        viewHolder.title.setText(files.get(position).getFileName());
        return convertView;
    }

    class GridViewHolder {
        public ImageView iconview;
        public TitleTextView title;
    }

}
